package com.woniuxy.microgoodsserver.auctionmag.mapper;

import com.woniuxy.microgoodsserver.bean.GoodsBrandBean;
import com.woniuxy.microgoodsserver.bean.GoodsSortBean;
import com.woniuxy.microgoodsserver.bean.ImageXcBean;
import com.woniuxy.microgoodsserver.bean.PageRequest;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface GoodsSortMapper {
    //商品品种通过id查询
    @Select("select id,kind_numble as kindNumble,kind_name as kindName," +
            "kind_type as kindType from t_goods_sort_info where id = #{id} and del_status=0")
    GoodsSortBean sortFindAllById(@Param("id")int id);

    //商品品种分页查询
    List<GoodsSortBean> sortFindAll(@Param("p") PageRequest request, @Param("s")GoodsSortBean GoodsSortBean);



    //品种增加
    @Options(useGeneratedKeys = true,keyProperty = "s.id")
    @Insert("insert into t_goods_sort_info " +
            "(kind_numble,kind_name,kind_type,del_status)" +
            " values(#{s.kindNumble},#{s.kindName},#{s.kindType},'0')")
    int SaveSort(@Param("s") GoodsSortBean goodsSortBean);


    //品种修改
    @Update("<script>" +
            "update t_goods_sort_info" +
            "<set>" +
            "<if test='s.kindNumble!= null'>" +
            " kind_numble = #{s.kindNumble}," +
            "</if>" +
            "<if test='s.kindName != null'>" +
            " kind_name = #{s.kindName}," +
            "</if>" +
            "</set>" +
            "where id = #{b.id}" +
            "</script>")
    int updateGoodSortBean(@Param("s") GoodsSortBean goodsSortBean);

    //品种删除
    @Update("<script>" +
            "update t_goods_sort_info" +
            "<set>" +
            " del_status = '1'" +
            "</set>" +
            "where id = #{b.id}" +
            "</script>")
    int delGoodSortBean(@Param("s") GoodsSortBean goodsSortBean);
}
